Q: The leaves of an expression tree always contain?
Solution: The leaves of an expression tree always contain the result of a given expression (i.e.) operands.
Q: A node can have a minimum of one child.
Solution: It is possible for a node to have at least one child, as is the case with the unary minus operator.
Q: What does the other nodes of an expression tree(except leaves) contain?
Solution: The nodes other than leaves always contain only operators. There cannot be any operand in those nodes.
Q: An expression tree is a kind of?
Solution: The expression tree is a binary tree. It contains operands at leaf nodes and remaining nodes are filled with operators. The operands and the operators can be arranged in any order (ascending, descending).
Q: The expression obtained by recursively producing a left expression, followed by an operator, followed by recursively producing a right expression is called?
Solution: It is an infix expression because the format of an infix expression is given by operand-operator-operand.
Q: The average depth of a binary tree is given as?
Solution: The average depth of a binary expression tree is mathematically found to be O(√N).
Q: An expression tree is created using?
Solution: A postfix expression is converted into an expression tree by reading one symbol at a time and constructing a tree respectively.
Q: ++a*bc*+defg is an?
Solution: It is a prefix expression obtained from a preorder traversal since it is of the form operator-operand-operand.
Q: An expression tree’s nodes can be deleted by calling?
Solution: In Binary trees, nodes are created by calling malloc and they are deleted by calling free.
Q: In an expression tree algorithm, what happens when an operand is encountered?
Solution: When an operand is encountered, create one node trees and push it on to the stack. When an operator is encountered, pop the pointers from last two trees from the stack.
You Have Score    | /10 |